package com.gin.kotlin.no_gay_alliance.argument

import android.os.Parcelable
import com.fasterxml.jackson.annotation.JsonIgnore
import com.gin.nga.response.topic.TopicDetail
import com.gin.nga.response.vote.VoteData
import kotlinx.parcelize.Parcelize

@Parcelize
data class VoteArgument(
    val topicId: Long,
    val vote: String,
) : Parcelable {
    constructor(topic:TopicDetail):this(
        topicId = topic.topicId!!,
        vote = topic.postMiscVar?.vote!!
    )

    @JsonIgnore
    fun getVoteData() = vote.takeIf { it.isNotEmpty() && it.contains("~") }?.let { VoteData(it) }
}
